﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="WebApplication1.test" MasterPageFile="~/masterpage/User.Master" %>

<asp:Content ID="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1" />
    <asp:Button ID="TestPrintBtn" runat="server" Text="Print" OnClick="TestPrintBtn_Click" />
        <asp:Button ID="Button2" runat="server" Text="Logic" OnClick="Button2_Click" />
        <asp:TextBox ID="TextBox1" runat="server" ClientIDMode="Static"></asp:TextBox>
     <div class="well">
      <table class="table">
        <thead>
          <tr>
           
            <th>Check in: <asp:TextBox  runat="server" class="span2"  Id="dpd1" ClientIDMode="Static"></asp:TextBox></th>
            <th>Check out: <asp:TextBox runat="server" class="span2"  id="dpd2" ClientIDMode="Static" ></asp:TextBox></th>
          </tr>
        </thead>
      </table>
          </div>
    <script src="js/prettify.js"></script>
  <script src="js/bootstrap-datepicker.js"></script>
	<script>
	    if (top.location != location) {
	        top.location.href = document.location.href;
	    }
	    $(function () {
	        window.prettyPrint && prettyPrint();
	        $('#dp1').datepicker({
	            format: 'mm-dd-yyyy'
	        });
	        $('#dp2').datepicker();
	        $('#dp3').datepicker();
	        $('#dp3').datepicker();
	        $('#dpYears').datepicker();
	        $('#dpMonths').datepicker();


	        var startDate = new Date(2012, 1, 20);
	        var endDate = new Date(2012, 1, 25);
	        $('#dp4').datepicker()
				.on('changeDate', function (ev) {
				    if (ev.date.valueOf() > endDate.valueOf()) {
				        $('#alert').show().find('strong').text('The start date can not be greater then the end date');
				    } else {
				        $('#alert').hide();
				        startDate = new Date(ev.date);
				        $('#startDate').text($('#dp4').data('date'));
				    }
				    $('#dp4').datepicker('hide');
				});
	        $('#dp5').datepicker()
				.on('changeDate', function (ev) {
				    if (ev.date.valueOf() < startDate.valueOf()) {
				        $('#alert').show().find('strong').text('The end date can not be less then the start date');
				    } else {
				        $('#alert').hide();
				        endDate = new Date(ev.date);
				        $('#endDate').text($('#dp5').data('date'));
				    }
				    $('#dp5').datepicker('hide');
				});

	        // disabling dates
	        var nowTemp = new Date();
	        var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);

	        var checkin = $('#dpd1').datepicker({
	            onRender: function (date) {
	                return date.valueOf() < now.valueOf() ? 'disabled' : '';
	            }
	        }).on('changeDate', function (ev) {
	            if (ev.date.valueOf() > checkout.date.valueOf()) {
	                var newDate = new Date(ev.date)
	                newDate.setDate(newDate.getDate() + 1);
	                checkout.setValue(newDate);
	            }
	            checkin.hide();
	            $('#dpd2')[0].focus();
	        }).data('datepicker');
	        var checkout = $('#dpd2').datepicker({
	            onRender: function (date) {
	                return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
	            }
	        }).on('changeDate', function (ev) {
	            checkout.hide();
	        }).data('datepicker');
	    });
	</script>
</asp:Content>


